﻿using System;

namespace Ue.Infrastructure.Caching
{
    public class CacheManager : ICacheManager
    {
        private readonly Type component;
        private readonly ICacheHolder cacheHolder;

        public CacheManager(Type component,ICacheHolder cacheHolder)
        {
            this.cacheHolder = cacheHolder;
            this.component = component;
        }

        #region ICacheManager 成员

        public TResult Get<TKey, TResult>(TKey key, Func<AcquireContext<TKey>, TResult> acquire)
        {
            return this.cacheHolder.GetCache<TKey, TResult>(this.component).Get(key,acquire);
        }

        public ICache<TKey, TResult> GetCache<TKey, TResult>()
        {
            return this.cacheHolder.GetCache<TKey, TResult>(this.component);
        }

        #endregion
    }
}
